package com.itheima.youdianda.utils;



import com.itheima.youdianda.dto.SysMenuVo;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @ClassName DiGuiUtil
 * @Description 递归类
 * @Author dcq
 * @Date 2023/2/15 10:20
 * @Version 1.0
 */
public class DiGuiUtil {
    public List<SysMenuVo> getChind(int pid , List<SysMenuVo> SysMenuVos){
        List<SysMenuVo>menuVos=new ArrayList<>();
        for (SysMenuVo item : SysMenuVos) {
           int pid1 = item.getPid();
            if (Objects.equals(pid1, pid)) {
                menuVos.add(item);
        }
            }
        for (SysMenuVo menuVo : menuVos) {
            menuVo.setChind(getChind(menuVo.getId(),SysMenuVos));
        }
       if(menuVos.size()==0){
           return new ArrayList<>();
       }
       return menuVos;





    }
}